home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 7.4 KB | 261 lines | [TEXT/ttxt] |
- -- Filename:
- -- JAILBIRD.SX
-
- -- Other Files Required:
- -- NONE
-
- -- Purpose:
- -- Demonstrates a simple working document
-
- -- Specialized Classes:
- -- None
-
- -- Instructions to User:
- -- This is the main script for the creation of the document object. To
- -- create the title container, run the loadme.sx script. The loadme script
- -- will then call the media.sx and jailbird.sx scripts.
- --
- -- When the jailbird.sxt title runs a window will appear with the title page.
- -- Click any where in this page to go to the next page. Subsequent pages will
- -- contain forward and backward buttons for traversing the document.
-
- -- Author:
- -- Kim Swix
-
- ------------------------------------------------------------------------
-
- in module docModule
-
- -- ***********************************************************************
- -- Functions
- -- ***********************************************************************
-
- function findPresenter presenter parentClass ->
- ( repeat while (presenter !== undefined) do
- ( if (isAKindOf presenter parentClass) do
- (return presenter)
- presenter := presenter.presentedBy
- )
- undefined
- )
-
- function butFwd ad self ->
- (
- local doc, bm
- doc := findPresenter self Document
- bm := doc[doc.cursor].frame[10].presenter.target
- forward doc
- makepurgeable bm
- if doc.cursor = doc.size do
- self.enabled := false
- )
-
- function butBack ad self ->
- (
- local doc, bm
- doc := findPresenter self Document
- bm := doc[doc.cursor].frame[10].presenter.target
- backward doc
- makepurgeable bm
- if doc.cursor < doc.size do
- ad.enabled := true
- )
-
- function makeTitleLayer bbox ->
- (
- local tlayer, sh, bkgndElem
- tlayer := new pageLayer boundary:bbox
- sh := new twodshape boundary:docCont["1000.bmp" as String]
- bkgndElem := new pageElement boundary:sh.boundary presenter:sh target:docCont["1000.bmp" as String]
- bkgndElem.x := bkgndElem.y := 0
- append tlayer bkgndElem
-
- local but, ctl, butElem
- but := new pushbutton
- but.releasedPresenter := (new twodshape boundary:bbox fill:undefined stroke:undefined)
- but.pressedPresenter := (new twodshape boundary:bbox fill:undefined stroke:undefined)
- but.activateAction := ( ad item -> forward doc)
- butElem := new pageElement boundary:but.boundary presenter:but target:but.target
- prepend tlayer butElem
-
- ctl := new actuatorController space:tlayer
- deleteOne ctl.protocols Actuator
- append ctl.protocols PageElement
- ctl.wholespace := true
-
- return tlayer
- )
-
- function makeTextBox txt brush ->
- (
- local tb, fnt
- tb := new textPresenter boundary:(new rect x2:100 y2:25) target:txt
- fnt := new platformFont name:"Helvetica" windowsName:"Arial"
- setdefaultattr tb @font fnt
- setdefaultattr tb @size 12
- setdefaultattr tb @brush brush
- return tb
- )
-
- function makeMugLayer bbox ->
- (
- local mlayer, tb, pe, bp
-
- mlayer := new pageLayer boundary:bbox
- bp := new brush color:bluecolor
-
- -- Create the Name page element
- tb := makeTextBox ("Name: " as text) blackbrush
- pe := new pageElement boundary:tb.boundary presenter:tb target:("Name: " as text)
- pe.x := 20
- pe.y := 125
- append mlayer pe
-
- -- Create the DOB page element
- tb := makeTextBox ("DOB: " as text) blackbrush
- pe := new pageElement boundary:tb.boundary presenter:tb target:("DOB: " as text)
- pe.x := 20
- pe.y := 148
- append mlayer pe
-
- -- Create the Height element
- tb := makeTextBox ("Height: " as text) blackbrush
- pe := new pageElement boundary:tb.boundary presenter:tb target:("Height: " as text)
- pe.x := 20
- pe.y := 171
- append mlayer pe
-
- -- Create the Weight element
- tb := makeTextBox ("Weight: " as text) blackbrush
- pe := new pageElement boundary:tb.boundary presenter:tb target:("Weight: " as text)
- pe.x := 20
- pe.y := 194
- append mlayer pe
-
- -- Create the PageNo element
- tb := makeTextBox (" " as text) blackbrush
- pe := new pageElement boundary:tb.boundary presenter:tb \
- target:( e -> getNth (getparentData e Page) 1)
- pe.x := 20
- pe.y := 225
- append mlayer pe
-
- -- Create the Name Field element
- tb := makeTextBox (" " as text) bp
- pe := new pageElement boundary:tb.boundary presenter:tb \
- target:( e -> getNth (getparentData e Page) 2)
- pe.x := 100
- pe.y := 125
- append mlayer pe
-
- -- Create the DOB Field element
- tb := makeTextBox (" " as text) bp
- pe := new pageElement boundary:tb.boundary presenter:tb \
- target:( e -> getNth (getparentData e Page) 3)
- pe.x := 100
- pe.y := 148
- append mlayer pe
-
- -- Create the Height Field element
- tb := makeTextBox (" " as text) bp
- pe := new pageElement boundary:tb.boundary presenter:tb \
- target:( e -> getNth (getparentData e Page) 4)
- pe.x := 100
- pe.y := 171
- append mlayer pe
-
- -- Create the Weight Field element
- tb := makeTextBox (" " as text) bp
- pe := new pageElement boundary:tb.boundary presenter:tb \
- target:( e -> getNth (getparentData e Page) 5)
- pe.x := 100
- pe.y := 194
- append mlayer pe
-
- -- Create the mugshot element
- local mugShape := new twodshape boundary:docCont["1001.bmp" as String]
- pe := new pageElement boundary:mugShape.boundary presenter:mugShape \
- target: (e -> getNth (getParentData e Page) 6)
- pe.x := pe.y := 20
- append mlayer pe
-
- -- Create the navigational buttons
- local tri1, tri2, gp, rp, rpDull, blDull
- gp := new brush color:greencolor
- rp := new brush color:redcolor
- rpDull := new brush color:redcolor pattern:grayPattern
- blDull := new brush color:blackcolor pattern:grayPattern
-
- tri1 := new path
- moveto tri1 0 0
- lineto tri1 0 50
- lineto tri1 25 25
- closePath tri1
-
- local fwd := new pushButton
- fwd.pressedPresenter := (new twodshape boundary:tri1 stroke:blackbrush fill:gp)
- fwd.releasedPresenter := (new twodshape boundary:tri1 stroke:blackbrush fill:rp)
- fwd.disabledPresenter := (new twodshape boundary:tri1 stroke:blDull fill:rpDull)
- fwd.activateAction := butFwd
-
- tri2 := new path
- moveto tri2 25 0
- lineto tri2 25 50
- lineto tri2 0 25
- closepath tri2
-
- local bwd := new pushbutton
- bwd.pressedPresenter := (new twodshape boundary:tri2 stroke:blackbrush fill:gp)
- bwd.releasedPresenter := (new twodshape boundary:tri2 stroke:blackbrush fill:rp)
- bwd.disabledPresenter := (new twodshape boundary:tri2 stroke:blDull fill:rpDull)
- bwd.activateAction := butBack
- bwd.authorData := fwd
-
- pe := new pageElement boundary:fwd.boundary presenter:fwd target:fwd.target
- pe.x := 265
- pe.y := 250
- append mlayer pe
-
- pe := new pageElement boundary:bwd.boundary presenter:bwd target:bwd.target
- pe.x := 10
- pe.y := 250
- append mlayer pe
-
- local ctl
- ctl := new actuatorController space:mlayer
- deleteOne ctl.protocols Actuator
- append ctl.protocols PageElement
- ctl.wholespace := true
-
- return mlayer
- )
-
- function makePage bbox frame data ->
- (
- local pg
- pg := new page boundary:bbox frame:frame target:data
-
- return pg
- )
-
- function makeDocument ->
- (
- local doc, titleLayer, mugShotLayer, prect
- prect := new rect x2:300 y2:300
- doc := new MyDocumentClass boundary:prect
- doc.name := "JailBirds"
-
- titleLayer := makeTitleLayer prect
- mugShotLayer := makeMugLayer prect
-
- append doc (makePage prect titleLayer undefined)
- append doc (makePage prect mugShotLayer #(("Page 2" as text), ("Barry"as text),\
- ( "2-12-93" as text), ("5 ft." as text), ("125 lbs." as text), docCont["1001.bmp" as String]))
- append doc (makePage prect mugShotLayer #(("Page 3" as text), ("Willie" as text),\
- ( "1-29-93" as text), ("6 in." as text), ("3 oz." as text), docCont["1002.bmp" as String]))
- append doc (makePage prect mugShotLayer #(("Page 4" as text), ("Cotton" as text),\
- ( "11-19-62" as text), ("1 ft." as text), ("3 lbs." as text), docCont["1003.bmp" as String]))
-
- return doc
- )
-